import { ADD, MINUS, FIXED, UNFIXED, SCROLL, UNSCROLL, SIGN, SIGNED, USER, USERED } from '../constants/counter'

const INITIAL_STATE = {
  num: 0,
  fixed: '',
  scroll: false,
  signStatus: false,
  hasUser:false
}

export default function counter(state = INITIAL_STATE, action) {
  switch (action.type) {
    case ADD:
      return {
        ...state,
        num: state.num + 1
      }
    case MINUS:
      return {
        ...state,
        num: state.num - 1
      }
    case FIXED:
      return {
        ...state,
        fixed: 'fixed'
      }
    case UNFIXED:
      return {
        ...state,
        fixed: ''
      }
    case SCROLL:
      return {
        ...state,
        scroll: true
      }
    case UNSCROLL:
      return {
        ...state,
        scroll: false
      }
    case SIGN:
      return {
        ...state,
        signStatus: true
      }
    case SIGNED:
      return {
        ...state,
        signStatus: false
      }
    case USER:
      return {
        ...state,
        hasUser: false
      }
    case USERED:
      return {
        ...state,
        hasUser: true
      }
    default:
      return state

  }
}
